Skip to content

Fix "File name too long" error when a title is used as a folder name - #1479

Merged
jmbannon merged 1 commit into
jmbannon:masterfrom
Nojyto:fix/truncate-long-subdirectory-names
Jun 23, 2026
Merged

Fix "File name too long" error when a title is used as a folder name#1479
jmbannon merged 1 commit into
jmbannon:masterfrom
Nojyto:fix/truncate-long-subdirectory-names

Conversation

@Nojyto

@Nojyto Nojyto commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Some presets put the video title into a folder name (not just the file name). The code only shortened the file name, never the folder name. So a title with multi-byte characters (like bold/fancy Unicode, which take 4 bytes each) could make the folder name go over the OS 255-byte limit and crash with OSError: [Errno 36] File name too long.

This fix shortens every folder in the path too, not just the file name, while keeping the file extension. output_directory is left alone so real folders aren't touched.

Added a test with a title made of 4-byte bold Unicode characters.

Relates to #1092, #1189

@Nojyto

Nojyto commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Please rerun CI, seems like there is a flaky issue unrelated to my changes.

def post_process(self, resolved: str) -> str:
return FilePathTruncater.to_native_filepath(
FilePathTruncater.maybe_truncate_file_path(resolved)
FilePathTruncater.maybe_truncate_file_name_path(resolved)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is maybe_truncate_file_path still used? If not lets remove it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be still used and should not be removed I think.

@jmbannon

Copy link
Copy Markdown
Owner

The failed test seems legit, something changed to the file paths but only in Windows? I will try to investigate tomorrow

@jmbannon

Copy link
Copy Markdown
Owner

Welp, you are right! This is indeed a pre-existing failure (and a very strange one). Merging now, thanks for this change!

@jmbannon
jmbannon merged commit 658f5ef into jmbannon:master Jun 23, 2026
34 of 36 checks passed
@Nojyto
Nojyto deleted the fix/truncate-long-subdirectory-names branch June 23, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants